#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

int Find ( int *S, int X ) {
    for ( ; S[X] >= 0; X = S[X] );
    return X;
}

int betterFind ( int *S, int X ) {
    if ( S[X] < 0 ) return X;
    else return S[X] = betterFind( S, S[X] );
}

void Union ( int* S, int root1, int root2 ) {
    /* root1 root2 are in different unions */
    if ( S[root2] < S[root1] ) S[root1] = root2;/* tree2 is taller */
    else {
        if ( S[root1] == S[root2] ) S[root1]--;
        S[root2] = root1;
    }
}

void Input_connection( int* S ) {
    int u, v;
    int root1, root2;
    scanf("%d %d\n", &u, &v);
    root1 = betterFind(S, u-1);
    root2 = betterFind(S, v-1);
    if ( root1 != root2 ) Union(S, root1, root2);
}

void Check_connection( int* S ) {
    int u, v;
    int root1, root2;
    scanf("%d %d\n", &u, &v);
    root1 = betterFind(S, u-1);
    root2 = betterFind(S, v-1);
    if ( root1 == root2 ) printf("yes\n");
    else printf("no\n");
}

void Check_network( int* S, int N ) {
    int i, cnt = 0;
    for ( i = 0; i < N; i++ ) if ( S[i] <= -1 ) cnt++;
    if ( cnt == 1 ) printf("The network is connected\n");
    else printf("There are %d components.\n", cnt);
}

int main () {
    int *S;
    int i, N;
    char in;
    scanf("%d", &N);
    S = (int*)malloc(sizeof(int)*N);
    for ( i = 0; i < N; i++ ) S[i] = -1;
    do {
        scanf("%c", &in);
        switch (in) {
        case 'I': Input_connection(S); break;
        case 'C': Check_connection(S); break;
        case 'S': Check_network(S,N); break;
        }
    } while ( in != 'S' );
    free(S);
    return 0;
}